# Maintainer: Frode Solheim <frode@fs-uae.net>

_realname=lhafile
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-lhafile")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.3.0
pkgrel=3
pkgdesc="LHA module for Python (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
license=('BSD')
url="https://fengestad.no/python-lhafile"
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=(${_realname}-${pkgver}.tar.gz::https://github.com/FrodeSolheim/python-lhafile/archive/v${pkgver}.tar.gz)
sha256sums=('5565641820813c76c74f2199f19f6ee0e3ae1e1c14de1a3a4ea3602f9094cd29')

prepare() {
  rm -rf "python-build-${CARCH}" | true
  cp -r "python-${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1

  install -m755 -d "${pkgdir}${MINGW_PREFIX}/share/licenses/python-lhafile"
  install -m644 COPYING.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-lhafile/"
}
